@extends('orange.layouts.indexPublic')
@section('title'){{ Site::get('area_name').'职场资讯_'.Site::get('area_name').'人力资源政策劳动法苑-'.Site::get('webname') }} @endsection
@section('headcss')
    @parent
    <link rel="stylesheet" href="{{asset('/orange/css/index/news.css')}}">
@endsection
{{--主体内容--}}
@section('content')
    {{--主导航--}}
    @include('orange.layouts.mainNav')
    {{--主导航结束--}}

    {{--主要内容--}}
    <div class="main">
        <div class="wrapper">
            {{--主要内容-资讯列表--}}
            <div class="content">
                <h2><span>最新动态</span></h2>
                <ul>
                    @if(count($latelyNews) > 0)
                        @foreach($latelyNews as $v)
                            @if($v->imgUrl != '')
                                <li>
                                    <div class="left">
                                        <img src="{{ $v->imgUrl }}" alt="" width="250" height="130">
                                    </div>
                                    <div class="right noLeft">
                                        <div class="title">
                                            <a href="{{ route('newsinfo',['id'=>$v->id]) }}" target="_blank">
                                                {{ str_limit($v->title,30) }}</a>
                                        </div>
                                        <div class="status">
                                            <span class="updateDate">{{ $v->updated_at }}</span>
                                            <span>阅读 {{ $v->readnum }}</span>
                                        </div>
                                        <p>
                                            <a href="{{ route('newsinfo',['id'=>$v->id]) }}" target="_blank">
                                                {{ $v->content }}</a>
                                        </p>
                                    </div>
                                </li>
                            @else
                                <li>
                                    <div class="right">
                                        <div class="title">
                                            <a href="{{ route('newsinfo',['id'=>$v->id]) }}" target="_blank">
                                                {{ str_limit($v->title,30) }}</a>
                                        </div>
                                        <div class="status">
                                            <span class="updateDate">{{ $v->updated_at }}</span>
                                            <span>阅读 {{ $v->readnum }}</span>
                                        </div>
                                        <p>
                                            <a href="{{ route('newsinfo',['id'=>$v->id]) }}" target="_blank">
                                                {{ $v->content }}</a>
                                        </p>
                                    </div>
                                </li>
                            @endif
                        @endforeach
                    @else
                        <li class="noCont">对不起，该标签对应内容暂时为空。。。</li>
                    @endif
                </ul>
                <div class="pageList">
                    @if(count($pageStr)>0)
                        {!! $latelyNews->appends($pageStr)->links() !!}
                    @else
                        {!! $latelyNews->links() !!}
                    @endif
                </div>
            </div>
            {{--主要内容-资讯列表结束--}}

            {{--侧边栏--}}
            <div class="aside">
                {{--求职标签--}}
                <div class="jobLabel">
                    <h2><span>求职标签</span></h2>
                    <ul>
                        <li><a href="{{  route('news') }}?search=销售">销售</a></li>
                        <li><a href="{{  route('news') }}?search=会计">会计</a></li>
                        <li><a href="{{  route('news') }}?search=计算机">计算机</a></li>
                        <li><a href="{{  route('news') }}?search=行政">行政</a></li>
                        <li><a href="{{  route('news') }}?search=物流">物流</a></li>
                        <li><a href="{{  route('news') }}?search=传媒">传媒</a></li>
                        <li><a href="{{  route('news') }}?search=法律">法律</a></li>
                        <li><a href="{{  route('news') }}?search=教师">教师</a></li>
                        <li><a href="{{  route('news') }}?search=编辑">编辑</a></li>
                        <li><a href="{{  route('news') }}?search=人力资源">人力资源</a></li>
                        <li><a href="{{  route('news') }}?search=主管">主管</a></li>
                        <li><a href="{{  route('news') }}?search=经理">经理</a></li>
                        <li><a href="{{  route('news') }}?search=化工">化工</a></li>
                        <li><a href="{{  route('news') }}?search=带薪年假">带薪年假</a></li>
                        <li><a href="{{  route('news') }}?search=电子商务">电子商务</a></li>
                        <li><a href="{{  route('news') }}?search=有年终奖">有年终奖</a></li>
                        <li><a href="{{  route('news') }}?search=酒店">酒店</a></li>
                        <li><a href="{{  route('news') }}?search=产品经理">产品经理</a></li>
                        <li><a href="{{  route('news') }}?search=双休">双休</a></li>
                        <li><a href="{{  route('news') }}?search=五险一金">五险一金</a></li>
                    </ul>
                </div>
                {{--资讯分类--}}
                <div class="classification">
                    <h2><span>资讯分类</span></h2>
                    <ul>
                        @if(count($secondClass) > 0 )
                            @foreach($secondClass as $k => $v)
                                <li @if($k % 2 != 0)class="noMarginRight"@endif><a href="{{ route('news') }}?class={{ $v->id }}">{{ $v->defectsname }}</a></li>
                            @endforeach
                        @endif
                    </ul>
                </div>
                {{--热门文章--}}
                <div class="hotArticles">
                    <h2><span>热门文章</span></h2>
                    <ul>
                        @if(count($hotNews) > 0 )
                            <?php $i = 1;?>
                            @foreach($hotNews as $v)
                                <li>
                                    @if($i == 1)
                                        <a href="{{ route('newsinfo',['id'=>$v->id]) }}" target="_blank">
                                            <span class="icon top1"></span><span class="cont">{{ msubstr($v->title,0,23) }}</span>
                                        </a>
                                    @elseif($i == 2)
                                        <a href="{{ route('newsinfo',['id'=>$v->id]) }}" target="_blank">
                                            <span class="icon top2"></span><span class="cont">{{ msubstr($v->title,0,23) }}</span>
                                        </a>
                                    @elseif($i == 3)
                                        <a href="{{ route('newsinfo',['id'=>$v->id]) }}" target="_blank">
                                            <span class="icon top3"></span><span class="cont">{{ msubstr($v->title,0,23) }}</span>
                                        </a>
                                    @else
                                        <a href="{{ route('newsinfo',['id'=>$v->id]) }}" target="_blank">
                                            <span class="num">{{$i}}</span><span class="cont">{{ msubstr($v->title,0,23) }}</span>
                                        </a>
                                    @endif
                                </li>
                                <?php $i++;?>
                            @endforeach
                        @endif
                    </ul>
                </div>
            </div>
            {{--侧边栏结束--}}
        </div>
    </div>
    {{--主要内容--}}
@endsection
{{--职位列表js--}}
@section('js')
    @parent
    <script>
        $(function(){
            //求职标签高亮
            var jobSearch = getQueryString("search");
            if(jobSearch !=null && jobSearch.toString().length>0){ //判断参数是否为空
                var $jobLabels = $(".aside .jobLabel li a"); //获取所有标签
                var jobLen = $jobLabels.length;
                for(var i = 0; i < jobLen; i++){//根据地址栏参数值找到对应的标签设为高亮
                    var index = i;
                    if($jobLabels.eq(index).html() == jobSearch){
                        $jobLabels.eq(index).addClass('active');
                    }
                }
            }

            //资讯分类标签高亮
            var classSearch = getQueryString("class");
            if(classSearch !=null && classSearch.toString().length>0){
                var $classification = $(".aside .classification li a"); //获取所有标签
                //根据地址栏参数值找到对应的标签设为高亮
                $classification.removeClass('active').eq(classSearch - 2).addClass('active');
            }
        });
        //获取地址栏某一参数的值
        function getQueryString(name){
            var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if(r!=null){
                return  decodeURI(r[2]); //对参数值进行解码操作
            }else{
                return null;
            }
        }
    </script>
@endsection